package com.zed.api.domain;

/**
 * {@link AggregatableNotMatchException}, 设置的聚合对象不匹配时抛出的例外
 *
 * @author Zed
 */
public class AggregatableNotMatchException extends RuntimeException {

    /**
     *
     */
    private static final long serialVersionUID = 5324073707365349917L;

    private Class<?> requiredType;
    private Class<?> aggregateType;

    /**
     * 构造方法
     *
     * @param requiredType  {@link Class},要求的类型
     * @param aggregateType {@link Class},实际的聚合类型
     */
    public AggregatableNotMatchException(Class<?> requiredType, Class<?> aggregateType) {
        super("Aggregatable not match: requiredType=" + requiredType.getName() +
                ", but aggregatable type is :" + aggregateType.getName() + ".");
        this.requiredType = requiredType;
        this.aggregateType = aggregateType;
    }

    /**
     * 要求的聚合根类型
     *
     * @return the requiredType
     */
    public Class<?> getRequiredType() {
        return requiredType;
    }

    /**
     * 实际的聚合根类型
     *
     * @return the aggregateType
     */
    public Class<?> getAggregateType() {
        return aggregateType;
    }


}
